// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";

import "@/assets/css/base.scss";
import "@/assets/css/font/iconfont.css";
import "./permission";
import moment from "moment";
import store from "@/store/index";
import "babel-polyfill";
import "default-passive-events";
import * as filters from "./filters";
import VueI18n from "vue-i18n";
import i18nMsg from "@/i18n/msg";
import tools from "./tools";
import "@/utils/directives/directives.js";
// 注册全局实用过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
// 注册全局函数
Vue.use(tools);
Vue.config.productionTip = false;
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
});
Vue.use(require("vue-moment"));
Vue.prototype.moment = moment;
Vue.use(VueI18n);
const i18n = new VueI18n({
  locale: store.state.locale,
  messages: i18nMsg
});

new Vue({
  el: "#app",
  router,
  store,
  components: { App },
  template: "<App/>",
  i18n,
  //为了使语言保存在vuex并且可以通过vuex切换
  watch: {
    "$store.state.locale"(v) {
      i18n.locale = v;
    }
  }
});

// 全局列表模板页面
import cListTemplate from "@/components/template/c-list-template.vue";
Vue.component("cListTemplate", cListTemplate);
// 全局普通模板页面
import cTemplate from "@/components/template/c-template.vue";
Vue.component("cTemplate", cTemplate);
// Form模板
import cFormTemplate from "@/components/template/c-form-template.vue";
Vue.component("cFormTemplate", cFormTemplate);

// 输入框数字
import cNumberInput from "@/components/form/c-number-input.vue";
Vue.component("cNumberInput", cNumberInput);
// 输入框数字区间
import cNumberRange from "@/components/form/c-number-range.vue";
Vue.component("cNumberRange", cNumberRange);
// 输入框金额
import cMoneyInput from "@/components/form/c-money-input.vue";
Vue.component("cMoneyInput", cMoneyInput);
// 输入框金额区间
import cMoneyRange from "@/components/form/c-money-range.vue";
Vue.component("cMoneyRange", cMoneyRange);
// 输入框地址
import cAddressInput from "@/components/form/c-address-input.vue";
Vue.component("cAddressInput", cAddressInput);
// 授信银行选择器
import cBankList from "@/components/form/c-bankList-select.vue";
Vue.component("cBankList", cBankList);

// 文件上传
import cUpload from "@/components/upload/c-upload.vue";
Vue.component("cUpload", cUpload);
// 文件上传(左对齐)
import cUploadLeft from "@/components/upload/c-upload-left.vue";
Vue.component("cUploadLeft", cUpload);
// 文件上传-导入
import cUploadExcel from "@/components/upload/c-upload-excel.vue";
Vue.component("cUploadExcel", cUploadExcel);
